<?php

/***  DOCUMENTATION LAYER

Ceo Sample Unit Test

Last Update: Aug 2007
  
DESCRIPTION
  this file provides a template for other simple unit tests.
  
NOTES
  $test_root dynamically sets root in order to keep tests working after
  they are moved to the __REPOSITORY directory
    
______________________________________________________________________________*/

$_tx0 = microtime();
$test_root = ( strpos(dirname(__FILE__), 'repository') === false ) ? '' : '../';


// Test Name
$test_name = 'sample test';

// Include Files
$test_root = ( strpos(dirname(__FILE__), '__REPOSITORY') === false ) ? '' : '../';
require_once($test_root . '../php_ceo/ext/input/form.class.php');

// Configure Test
$debug = 0;


// Test Procedure
	// build form
	$TestForm = new CeoForm($debug);
	$TestForm->add_element($name='text_input', $type='input_text', $label='input some text', $is_required=1, $maxlength=255, $minlength=4);
	$TestForm->add_element($name='email_input', $type='input_email',$label='email address', $is_required=1);
	$TestForm->add_element($name='url_input', $type='input_url',$label='web address', $is_required=0);
  $TestForm->add_element($name='error_test', $type='unknown',$label='deliberate error', $is_required=0);
	
	// debug
	if ( !empty($_POST) ) $TestForm->print_d(print_r($_POST,1));
		
	// print form
	#$TF_ElTextInput->dump();
	$_HTML['submit_bx'] = $TestForm->add_button($type='submit', $label='submit it!');
	$_HTML['text_input'] = $TestForm->EL['text_input']->print_block();
	$_HTML['email_input'] = $TestForm->EL['email_input']->print_block();
	$_HTML['url_input'] = $TestForm->EL['url_input']->print_block();
	
	$_HTML['form'] = <<<HTML
<div class="form">
<form name="test" method="post" action="{$_SERVER['PHP_SELF']}">
{$_HTML['text_input']}
{$_HTML['email_input']}
{$_HTML['url_input']}
{$_HTML['submit_bx']}
</form>
</div>
HTML;

	echo "<pre style='background:#ccc;'>" . htmlspecialchars($_HTML['form']) . "</pre>";

	
	// debug
	$TestForm->EL['text_input']->random_var = 'this should be present in element object and form object';
	$TestForm->print_d("<br /><br />let's dump some objects");
	$TestForm->EL['text_input']->dump();
	$TestForm->dump();


// Footer
$_txn = microtime();
$stx = number_format(((substr($_txn,0,9)) + (substr($_txn,-10)) - (substr($_tx0,0,9)) - (substr($_tx0,-10))),4); 
echo "<h6>test '$test_name' complete in $stx s</h6>";
?>
